@extends('layouts.default')
@section('content')
    <div class="container">
        <div class="row row-display row-centered">
            <div class="col-md-6 col-centered">
                <!-- /.box-header -->
                <!-- form start -->
                <form role="form" action="{{route('users.updaterole', $user->id)}}" method="post">
                    {{ method_field('PUT') }}
                    {{ csrf_field() }}
                    <div class="box-body">
                        <div class="form-group">
                            <label>角色</label>
                            <select class="form-control" multiple="multiple" name="role[]">
                                @foreach($roles as $role)
                                    @if($user->hasRole($role->name))
                                        <option value="{{ $role->id }}" selected>{{ $role->name }}</option>
                                    @else
                                        <option value="{{ $role->id }}">{{ $role->name }}</option>
                                    @endif
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="submit" class="btn btn-primary pull-left">保存</button>
                        <a href="{{ url()->previous() }}" class="btn btn-primary pull-right">返回</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
@stop